package com.example.mobile2032021606170hsy0615;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

public class MySQLiteOpenHelper extends SQLiteOpenHelper {
    public MySQLiteOpenHelper(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        String aql="create table users(_id integer primary key autoincrement,name varch(20) not null,age integer,score float)";
        db.execSQL(aql);
        ContentValues values=new ContentValues();
        values.put("name","王小平");
        values.put("age","18");
        values.put("score","90");
        db.insert("users",null,values);
        values.put("name","小红");
        values.put("age","28");
        values.put("score","91");
        db.insert("users",null,values);
        values.put("name","张晓");
        values.put("age","19");
        values.put("score","50");
        db.insert("users",null,values);

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
